package com.hzvictory.hotel_system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
//import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.hzvictory.hotel_system.common.annotation.Log;
import com.hzvictory.hotel_system.common.core.controller.BaseController;
import com.hzvictory.hotel_system.common.core.domain.AjaxResult;
import com.hzvictory.hotel_system.common.enums.BusinessType;
import com.hzvictory.hotel_system.pojo.entity.Dishcategory;
import com.hzvictory.hotel_system.service.IDishcategoryService;
//import com.hzvictory.hotel_system.common.utils.ExcelUtil;
import com.hzvictory.hotel_system.common.core.page.TableDataInfo;

/**
 * 菜品分类管理Controller
 *
 * @author hzvictory
 * @date 2025-07-24
 */
@RestController
@RequestMapping("/system/dishcategory")
public class DishcategoryController extends BaseController
{
    @Autowired
    private IDishcategoryService dishcategoryService;

    /**
     * 查询菜品分类管理列表
     */
    //@PreAuthorize("@ss.hasPermi('system:dishcategory:list')")
    @GetMapping("/list")
    public TableDataInfo list(Dishcategory dishcategory)
    {
        startPage();
        List<Dishcategory> list = dishcategoryService.selectDishcategoryList(dishcategory);
        return getDataTable(list);
    }

    /**
     * 导出菜品分类管理列表
     */
    //@PreAuthorize("@ss.hasPermi('system:dishcategory:export')")
//    @Log(title = "菜品分类管理", businessType = BusinessType.EXPORT)
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, Dishcategory dishcategory)
//    {
//        List<Dishcategory> list = dishcategoryService.selectDishcategoryList(dishcategory);
//        ExcelUtil<Dishcategory> util = new ExcelUtil<Dishcategory>(Dishcategory.class);
//        util.exportExcel(response, list, "菜品分类管理数据");
//    }

    /**
     * 获取菜品分类管理详细信息
     */
    //@PreAuthorize("@ss.hasPermi('system:dishcategory:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(dishcategoryService.selectDishcategoryById(id));
    }

    /**
     * 新增菜品分类管理
     */
    //@PreAuthorize("@ss.hasPermi('system:dishcategory:add')")
    @Log(title = "菜品分类管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Dishcategory dishcategory)
    {
        return toAjax(dishcategoryService.insertDishcategory(dishcategory));
    }

    /**
     * 修改菜品分类管理
     */
    //@PreAuthorize("@ss.hasPermi('system:dishcategory:edit')")
    @Log(title = "菜品分类管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Dishcategory dishcategory)
    {
        return toAjax(dishcategoryService.updateDishcategory(dishcategory));
    }

    /**
     * 删除菜品分类管理
     */
    //@PreAuthorize("@ss.hasPermi('system:dishcategory:remove')")
    @Log(title = "菜品分类管理", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(dishcategoryService.deleteDishcategoryByIds(ids));
    }
}
